package kg.aibek.projecteuler.p10;

import java.util.HashSet;
import java.util.Set;

public class Problem21 {
	Set<Integer> set = new HashSet<Integer>();

	public void solve() {
		for (int i = 1; i <= 10000; i++) {
			int b = getFactorSum(i);
			if (b != i && getFactorSum(b) == i) {
				set.add(i);
				set.add(b);
			}
		}

		int count = 0;
		for (Integer i : set) {
			count += i;
		}

		System.out.println(count);
	}

	private int getFactorSum(int number) {
		int c = 1;

		for (int i = 2; i <= number / 2; i++) {
			if (number % i == 0) {
				c += i;
			}
		}
		return c;
	}

	public static void main(String[] args) {
		Problem21 p = new Problem21();
		p.solve();
	}
}
